package com.yangle.frame.common.service;

import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by yangle on 2018/6/5.
 */
@Service
public class RedisServiceImpl {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    public void set(String id, Object name) {
        ValueOperations<String, Object> vo = redisTemplate.opsForValue();
        vo.set(id, name);
    }


    public Object get(String id) {
        ValueOperations<String, Object> vo=redisTemplate.opsForValue();
        return vo.get(id);
    }



    public void update(String id, Object name) {
        ValueOperations<String, Object> vo=redisTemplate.opsForValue();
        vo.set(id, name);

    }



    public void delete(String id) {
        ValueOperations<String, Object> vo=redisTemplate.opsForValue();
        vo.getOperations().delete(id);
    }

        public void clear(){
            ValueOperations<String, Object> value = redisTemplate.opsForValue();
            System.out.println(value);

        }

}